#!/bin/bash

#------------------------------------------------------------------------------
#Filename:	74819-tar.sh
#Version:	1.1
#Date:	        2013/08/02
#Author:	yuanhui.shi
#Email:	        yuanhui.shi@cs2c.com.cn
#Summary:	02.01系统核心功能-06基础命令行工具-16tar工具-03tar程序压缩文件
#Notes:	        检验tar命令
#Copyright:	China Standard Software Co.,Ltd.
#History:
#	        Version 1.0,2013/07/11
#	        -The first one
#	        Version 1.1,2013/09/03
#	        -Modify the script to satisfy the shell standard
#------------------------------------------------------------------------------

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH

source ../../lib/Echo.sh

function CleanData ()
{
  rm -rf test
  rm -rf test.tar.bz2 
  EchoInfo "74819-tar.sh执行完毕"
}

trap "CleanData" EXIT

echo "hello!" > test

EchoInfo "检验tar命令是否可用，参数是cvf"

tar cvf test.tar  test &> /dev/null
test -n "`file test.tar |grep 'POSIX tar archive (GNU)'`" 
EchoResult "tar命令可用"

rm -rf test.tar

EchoInfo "检验tar命令是否可用，参数是zcvf"

tar zcvf test.tar.gz  test &> /dev/null
test -n "`file test.tar.gz |grep 'gzip compressed data'`" 
EchoResult "tar命令可用"

rm -rf test.tar.gz

EchoInfo "检验tar命令是否可用，参数是jcvf，tar压缩格式tar.bz2"

tar jcvf test.tar.bz2  test &> /dev/null
test -n "`file test.tar.bz2 |grep 'bzip2 compressed data'`" 
EchoResult "tar命令可用"

rm -rf test.tar.bz2
